Skip to content

[Core] Support timeout error in requests+aiohttp transports#43201

Merged
annatisch merged 9 commits intomainfrom
core-serviceresponsetimeouterror
Oct 27, 2025
Merged

[Core] Support timeout error in requests+aiohttp transports#43201
annatisch merged 9 commits intomainfrom
core-serviceresponsetimeouterror

Conversation

@annatisch
Copy link
Member

Fixes #43200

@annatisch annatisch changed the title [Core] Support timeout error in requests transport [Core] Support timeout error in requests+aiohttp transports Oct 19, 2025
@annatisch annatisch marked this pull request as ready for review October 20, 2025 06:39
Copilot AI review requested due to automatic review settings October 20, 2025 06:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances timeout error handling in the Azure Core SDK by introducing more specific timeout exception types (ServiceRequestTimeoutError and ServiceResponseTimeoutError) to distinguish between connection and read timeout scenarios. The changes affect both synchronous (requests) and asynchronous (aiohttp) transports.

Key Changes:

  • Replaced generic ServiceRequestError and ServiceResponseError with specific timeout exceptions where applicable
  • Updated exception handling in transport layers to properly categorize timeout errors
  • Refactored exception handling patterns from try-except-reraise to try-finally blocks
  • Added comprehensive test coverage for timeout scenarios

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sdk/core/azure-core/azure/core/pipeline/transport/_requests_basic.py Updated exception handling to use specific timeout error types for read timeouts and connection timeouts in both send() method and StreamDownloadGenerator
sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py Changed asyncio.TimeoutError handling to raise ServiceResponseTimeoutError instead of generic ServiceResponseError
sdk/core/azure-core/azure/core/rest/_aiohttp.py Added comprehensive exception handling in read() method to catch and convert aiohttp exceptions to appropriate Azure Core exceptions
sdk/core/azure-core/azure/core/pipeline/_tools.py Simplified exception handling by replacing try-except-reraise with try-finally pattern
sdk/core/azure-core/azure/core/pipeline/_tools_async.py Simplified exception handling by replacing try-except-reraise with try-finally pattern
sdk/core/azure-core/tests/test_basic_transport.py Added test cases for timeout scenarios in requests transport, covering both connection and response timeouts
sdk/core/azure-core/tests/async_tests/test_basic_transport_async.py Added test cases for timeout scenarios in aiohttp transport, handling version-specific behavior
sdk/core/azure-core/tests/test_stream_generator.py Updated test expectations from requests.exceptions.ConnectionError to ServiceResponseError

Copy link
Contributor

@iscai-msft iscai-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I've run our pipeline with these core changes (see here) and linux tests are passing. windows paths are failing bc of path too long since I'm doing a egg install of this git branch, so we can ignore those. Thanks @annatisch!

Copy link
Member

@pvaneck pvaneck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a changelog entry?

@annatisch annatisch merged commit 4adcc52 into main Oct 27, 2025
54 checks passed
@annatisch annatisch deleted the core-serviceresponsetimeouterror branch October 27, 2025 22:08
JennyPng pushed a commit to JennyPng/azure-sdk-for-python that referenced this pull request Nov 3, 2025
)

* Support timeout error in requests transport

* Requests transport error updates

* Test updates

* Fix imports

* Fix black

* aiohttp fixes

* Fix tests

* Even blacker

* Update CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong Error Type for read timeouts

4 participants